package onlinecalsys.client.view.gui;


import java.awt.GridLayout;
import java.awt.image.BufferedImage;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;

/*
 * LabelDemo.java needs one other file:
 *   images/middle.gif
 */
public class Icon extends JPanel {
    public Icon() {
        super(new GridLayout(1,1));  //3 rows, 1 column
        JLabel label1, label2, label3;
        
        

        ImageIcon icon = createImageIcon("images/middle1.png",
                                         "a pretty but meaningless splat");
        

        //Create the first label.
        label1 = new JLabel("",
                            icon,
                            JLabel.CENTER);
        //Set the position of its text, relative to its icon:

        //Create the other labels.

        //Create tool tips, for the heck of it.

        //Add the labels.
        add(label1);
        
        
    }

    /** Returns an ImageIcon, or null if the path was invalid. */
    protected static ImageIcon createImageIcon(String path,
                                               String description) {
        java.net.URL imgURL = Icon.class.getResource(path);
        if (imgURL != null) {
            return new ImageIcon(imgURL, description);
        } else {
            System.err.println("Couldn't find file: " + path);
            return null;
        }
    }

    /**
     * Create the GUI and show it.  For thread safety,
     * this method should be invoked from the
     * event dispatch thread.
     */
    private static void createAndShowGUI() {
        //Create and set up the window.
        JFrame frame = new JFrame("LabelDemo");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        //Add content to the window.
        frame.add(new Icon());
        frame.setSize(100, 100);

        //Display the window.
//        frame.pack();
        
      //load frame logo
		 BufferedImage image = null;
        try {
            image = ImageIO.read(frame.getClass().getResource("images/middle1.png"));
        } catch (IOException e) {
       	 new Error("failed loading middle1.png");
        } catch (Exception e) {
       	 new Error("failed loading middle1.png");
        }
        frame.setIconImage(image);
        frame.setVisible(true);
        
        
    }

    public static void main(String[] args) {
        //Schedule a job for the event dispatch thread:
        //creating and showing this application's GUI.
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
		//Turn off metal's use of bold fonts
                
		createAndShowGUI();
            }
        });
    }
}

